package com.alibaba.citrus.cr.order.open.api.facade.service.notifyquantity;

import com.alibaba.cz.base.tool.Nullable;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author: yuhw
 * @date: 2024年03月01日 15:33
 **/
@Component
public class FulfillmentNotifyQuantityHandlerManager implements InitializingBean {
    @Resource
    private List<FulfillmentNotifyQuantityHandler> fulfillmentNotifyQuantityHandlers;

    private Map<String,FulfillmentNotifyQuantityHandler> handlerMap = Maps.newHashMap();

    @Override
    public void afterPropertiesSet() throws Exception {
        Nullable.stream(fulfillmentNotifyQuantityHandlers).forEach(handler -> {
            handlerMap.put(handler.getTransferOrderType(),handler);
        });
    }

    public FulfillmentNotifyQuantityHandler getFulfillmentNotifyQuantityHandler(String transferOrderType){
        return handlerMap.get(transferOrderType);
    }
}
